package com.feib.soeasy.dao.hibernate;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;

import org.hibernate.Criteria;
import org.hibernate.criterion.Order;
import org.hibernate.criterion.Restrictions;
import org.springframework.stereotype.Repository;

import com.feib.soeasy.dao.P0028DetailDao;
import com.feib.soeasy.dao.P0028MasterDao;
import com.feib.soeasy.model.P0028Detail;
import com.feib.soeasy.model.P0028Master;

/**
 * @title (#)P0028DetailHibernateDao.java<br>
 * @description P0028Detail Dao 實作<br>
 * @author Leo Lee<br>
 * @version 1.0.0 2011/12/08
 * @copyright Far Eastern International Bank Copyright (c) 2010<br>
 * @2011/12/08 create by Leo Lee<br>
 */
@Repository("p0028DetailDao")
public class P0028DetailHibernateDao extends BaseHibernateDao<P0028Detail, Long> implements P0028DetailDao{

	@Override
	public List<P0028Detail> queryP0028DetailByUserno(String userno,Date qryDateFrom , Date qryDateTo)
	{

		SimpleDateFormat dateFormat = new SimpleDateFormat("yyyyMMdd");
		String from = dateFormat.format(qryDateFrom);
		String to = dateFormat.format(qryDateTo);
		
		
		Criteria criteria = getSession().createCriteria(P0028Detail.class);
		criteria.add(Restrictions.eq("userno", userno));
		criteria.add(Restrictions.between("aday", from, to));
		criteria.addOrder(Order.asc("aday").asc("atime").asc("p0028Dpk"));
		List<P0028Detail> list = criteria.list();
		return list;
	}


}
